home *** CD-ROM | disk | FTP | other *** search
- /* List Manager test
- Walter R. Smith, 21 April 1986
-
- This application is not actually linkable without my library
- UILib, but it does illustrate the most-used List Manager calls.
-
- This puts a vertically-scrollable list of text in the window.
- Double-clicking on an item deletes it from the list.
- */
-
- #include <WindowMgr.h>
- #include <EventMgr.h>
- #include <UILib.h>
- #include <ListMgr.h>
-
- Handle mymenus[1];
- DoMenu() {}
- DoKey() {}
-
- WindowRecord mywin;
- ListHandle mylist;
-
- myupdate(win)
- WindowPeek win;
- {
- Rect box;
-
- box = (*mylist)->rView;
- InsetRect(&box, -1, -1);
- FrameRect(&box);
- LUpdate(thePort->visRgn, mylist);
- }
-
- myclose()
- {
- ExitToShell();
- }
-
- myclick(win, where)
- WindowPeek win;
- Point where;
- {
- long w;
-
- if (LClick(where, 0, mylist)) {
- w = LLastClick(mylist);
- LDelRow(1, (int) (w>>16), mylist);
- InvalRect(&(*mylist)->rView);
- }
- }
-
- main()
- {
- Rect bounds, lbounds, databounds;
- Point csize, cell;
- int i;
- static char *msgs[] = { "\pOranges", "\pLemons", "\pStrawberries",
- "\pApples", "\pBananas", "\pT. S. Eliot", "\pKiwi", "\pPineapples",
- "\pCoconut", "\pWatermelon" };
-
- InitBS();
-
- SetRect(&lbounds, 40, 40, 120, 40+5*15);
- SetRect(&bounds, 40, 40, 180, 120+5*15);
- BSNewWindow(&mywin, &bounds, "\pList Manager Test", 1, 0, 1,
- 0L, myupdate, myclose, myclick, 0);
- lbounds.right -= 15;
- SetRect(&databounds, 0, 0, 1, 0);
- csize.h = 150;
- csize.v = 15;
- mylist = LNew(&lbounds, &databounds, csize, 0, &mywin,
- TRUE, TRUE, TRUE, TRUE);
- LAddRow(10, 0, mylist);
- cell.h = 0;
- for (cell.v = 0; cell.v < 10; cell.v++)
- LSetCell(msgs[cell.v]+1, (int) *msgs[cell.v], cell, mylist);
-
- while (1) BSOneEvent();
- }
-